package com.cynoware.busappmas.task;

import java.io.File;

import android.content.Context;
import android.content.Intent;

import com.cynoware.busappmas.util.GeneralUtil;

public class downloadSpeed extends Thread{
	 File f;
	 boolean isTrue=true;
	 Context context;
	 public downloadSpeed(File f, Context context){ 
		 this.f=f;
		 this.context=context;
	 }
	 public void run(){
		 long localSize;
		 long foreSize=0,subSize;
		 while(isTrue){
			 if(f.exists()) localSize=f.length();
			 else localSize=0;
			 subSize=(localSize-foreSize)/1024;
			 foreSize=localSize;
			 Intent mIntent = new Intent("downloadspeed");  
             mIntent.putExtra("speed",String.valueOf(subSize));  
             context.sendBroadcast(mIntent);  
//			 System.out.println("*******************"+String.valueOf(subSize));
			 GeneralUtil.sleep(1000);
		 }
	 }
	 public void stops(){
		 isTrue=false;
	 }
	 
	 
}
